package hah;


//滑动窗口问题
public class SlidingWindow {
    public int slidingWindow(int[] A,int K){
        int len=A.length;
        int ans=0;
        int left=0;
        int right=0;
        int countzeros=0;
        while(right<len){
            if (A[right]==0){
                countzeros++;
            }
            while(countzeros>K){
                if (A[left]==0){
                    countzeros--;
                }
                left++;
            }
            ans=Math.max(ans,right-left+1);
            right++;
        }
        return ans;
    }
}
